package com.general.client.widgets.combobox;

import com.general.client.callback.Callback;

public interface IComboBox<T> {
	/**
	 * because it is a list, multiple items with same value allowed
	 * 
	 * @param value
	 *            - value of item
	 * @param label
	 *            - label to represent the value
	 */
	void addItem(T value, String label);

	/**
	 * set selected item
	 * 
	 * @param value
	 *            - if multiple items with same value than will select first if
	 *            value not in list - will do nothing null to to select none
	 */
	void setSelected(T value);

	/**
	 * set selected item
	 * 
	 * @param index
	 *            - index of item to select. -1 to select none. index out of
	 *            range (except -1) will do nothing
	 */
	void setSelected(int index);

	/**
	 * get selected value
	 * 
	 * @return selected value. null if none selected \ empty list
	 */
	T getSelected();

	/**
	 * get the index of currently selected value
	 * 
	 * @return index of currently selected value. -1 if none selected \ empty
	 *         list
	 */
	int getSelectedIndex();

	/**
	 * will be called when selected item is changed called even on setSelected
	 * 
	 * @param callback
	 */
	void onSelectedItemChanged(Callback<T> callback);

	/**
	 * set max height of the combo list. causes the appearance of a scrollbar at
	 * all times
	 * 
	 * @param maxHeight
	 */
	void setMaxHeight(String maxHeight);

}
